package main

import "fmt"

func main() {
	fmt.Println("this is a for test")
	arr := [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
	arr1 := [...]int{1, 2, 3}
	fmt.Println(arr)
	fmt.Println(arr1)

	str1 := "123456789"
	for i, v := range str1 {
		ii := v
		fmt.Printf("%d-%c,", i, ii)
	}
	for i := 1; i < 10; i++ {
		for j := 1; j <= i; j++ {
			fmt.Printf("%dx%d=%d,", i, j, i*j)
		}
		fmt.Println()

	}

	var s1 []string
	fmt.Println(s1)
	s1 = []string{"sss", "ttt"}
	var s2 []int
	a1 := [...]int{1, 2, 3, 4, 5, 6, 7, 8}
	s2 = a1[1:5]
	fmt.Println(s2) //[2 3 4 5]
	s3 := a1[:4]
	s4 := a1[3:]
	s5 := a1[:]
	fmt.Println(s3) //[1 2 3 4]
	//切片指向底层数组岛第一个元素到最后
	fmt.Printf("%d--%d\n", len(s3), cap(s3))
	fmt.Println(s4) //[4 5 6 7 8]
	fmt.Println(s5) //[1 2 3 4 5 6 7 8]
	p1 := person{"huanglu", 20}
	p1.guonian()
	fmt.Println(p1)
}

type person struct {
	name string
	age  int
}

//指针接受者
func (p *person) guonian() {
	p.age++
}
